package de.bloxel.core;

import com.jme3.asset.AssetManager;
import com.jme3.asset.TextureKey;
import com.jme3.material.Material;
import com.jme3.math.Vector2f;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.texture.Texture;

public class Bloxel {

  private final Geometry geometry;

  public Bloxel(final Vector3f thePosition, final AssetManager theAssetManager) {
    final Box box = new Box(thePosition, 1.0f, 1.0f, 1.0f);
    box.scaleTextureCoordinates(new Vector2f(1f, .5f));
    geometry = new Geometry("bloxel", box);
    final Material material = new Material(theAssetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
    final TextureKey key = new TextureKey("Textures/Terrain/splat/grass.jpg");
    key.setGenerateMips(true);
    final Texture tex = theAssetManager.loadTexture(key);
    material.setTexture("ColorMap", tex);
    geometry.setMaterial(material);
  }

  public Geometry getGeometry() {
    return geometry;
  }

}
